package com.big.merchan.controller.api;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.big.common.result.Result;
import com.big.merchan.service.MerchandiseCommentService;
import com.big.model.model.merchandise.comment.MerchandiseComment;
import com.tencentcloudapi.tbm.v20180129.models.CommentInfo;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 评论,回复
 */
@RestController
@RequestMapping("/api/merchan/commReply")
public class MerchandiseCommentReplyController {


    @Autowired
    MerchandiseCommentService merchandiseCommentService;


    @ApiOperation(value = "评论列表")
    @GetMapping("/commInfos/{mId}/{page}/{limit}")
    public Result  commInfos (
            @PathVariable String mId,
            @PathVariable Long page,
            @PathVariable Long limit ){
        Page<MerchandiseComment>pages=new Page<>(page,limit);
        IPage<MerchandiseComment> merchandiseCommentIPage = merchandiseCommentService.CommentInfos(pages,mId);
        return Result.ok(merchandiseCommentIPage);
    }


    @ApiOperation(value = "订单评论")
    @PostMapping("/saveComment")
    public Integer  saveComment (@RequestBody MerchandiseComment merchandiseComment ){
        return  merchandiseCommentService.saveMerchandiseComment(merchandiseComment);
    }


}
